Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Polygon holes #7397

Closed
wants to merge 2 commits into from
Closed

Polygon holes #7397

wants to merge 2 commits into from

Conversation

1ec5
Copy link
Contributor

@1ec5 1ec5 commented Dec 13, 2016

A slapdash attempt at reviving #5170 to add support for holes in Polygon and PolygonOptions. I resolved the conflicts without the aid of an IDE, so this PR needs close scrutiny – there’s probably quite a bit of copy 🍝 in here.

Fixes #1729.

@1ec5 1ec5 added Android Mapbox Maps SDK for Android annotations Annotations on iOS and macOS or markers on Android feature labels Dec 13, 2016
@1ec5 1ec5 self-assigned this Dec 13, 2016
@mention-bot
Copy link

@1ec5, thanks for your PR! By analyzing this pull request, we identified @jfirebaugh, @zugaldia and @ansis to be potential reviewers.

@1ec5 1ec5 force-pushed the 1ec5-android-polygon-hole-5170 branch 6 times, most recently from 774a2aa to 87be52b Compare December 16, 2016 05:11
Copy link
Contributor

@ivovandongen ivovandongen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@1ec5 I don't see any holes in the example.
screenshot_20161216-110512

/**
* Polygon is a geometry annotation that's a closed loop of coordinates.
*/
public final class Polygon extends MultiPoint {

private List<List<LatLng>> holes;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make this a final list and initialize in declaration?

* @param points A {@link List} {@link List}s of {@link LatLng} points making up the holes.
*/
public void setHoles(List<? extends List<LatLng>> holes) {
this.holes = new ArrayList<>(holes);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can just update the member list with the collection, so the reference is not exposed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean this.holes = holes? I think the idea was to make a copy of the list, similar to MultiPoint.setPoints().


std::size_t size = jni::GetArrayLength(*env, *jarrayHoles);
for (std::size_t j = 0; j < size; j++) {
jni::jobject* hole = reinterpret_cast<jni::jobject*>(jni::GetObjectArrayElement(*env, *jarrayHoles, j));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cast is redundant, jni::GetObjectArrayElement returns jni::jobject* already

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2ec060543899367c3b1f9026117488d8c133ec10.

@1ec5
Copy link
Contributor Author

1ec5 commented Dec 16, 2016

Thanks for taking a look!

I don't see any holes in the example.

I think the example originally worked, but now the star's outer ring has been moved to a static member of the class instead of a local array. For the purposes of this example, I think we'll be able to define the hole similarly to the outer ring instead of trying to define the hole dynamically.

@1ec5 1ec5 force-pushed the 1ec5-android-polygon-hole-5170 branch 2 times, most recently from 2ec0605 to ac4d3b8 Compare January 27, 2017 08:16
@1ec5
Copy link
Contributor Author

1ec5 commented Jan 27, 2017

I modernized the example activity, though I haven’t tried it yet.

@zugaldia
Copy link
Member

zugaldia commented Feb 2, 2017

@1ec5 Polygon looks different, but I still see no holes:

screenshot_20170202-150032

@1ec5
Copy link
Contributor Author

1ec5 commented Feb 3, 2017

Thanks @zugaldia. I need to actually get around to setting up a development environment. GitHub comments don't make for a good debugger. 😅

@zugaldia
Copy link
Member

zugaldia commented Feb 3, 2017

@1ec5 totally :) wanna work on that today to benefit from the small delta in our coordinates?

Neal Sanche and others added 2 commits February 5, 2017 14:07
@caHarkness
Copy link

I see that there's a pull request open:
add support for multipolygons and polygon interior holes #1729

Does this mean that in a future version, it is guaranteed that we will have interior holes on Android? I've been following this issue for a while and have seen iOS get a lot of attention on the subject, but I am more interested in Android.

@1ec5 1ec5 added this to the android-future milestone Mar 24, 2017
@1ec5
Copy link
Contributor Author

1ec5 commented Mar 24, 2017

#1729 is the bug report; this is the PR that would fix it for Android. The issue was fixed for iOS and macOS in #5110, which also involved adding support in the core C++ code for polygon holes. This PR plumbs that support through JNI to the Android SDK and adds an activity to demonstrate the feature. Unfortunately, the activity currently demonstrates that the JNI implementation is broken. @Guardiola31337 is currently assigned to take a look. We’re still scoping out what the next release will contain, but this PR is on our radar.

@1ec5 1ec5 mentioned this pull request Mar 29, 2017
9 tasks
@1ec5
Copy link
Contributor Author

1ec5 commented Apr 11, 2017

#8557 landed instead.

@1ec5 1ec5 closed this Apr 11, 2017
@1ec5 1ec5 deleted the 1ec5-android-polygon-hole-5170 branch April 11, 2017 17:20
@lilykaiser lilykaiser removed this from the android-future milestone Sep 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android annotations Annotations on iOS and macOS or markers on Android feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add support for multipolygons and polygon interior holes
7 participants